# 读取原文件
with open('nursery.txt', 'r') as file:
    lines = file.readlines()

# 去掉每行末尾的逗号，并写入新文件
with open('nursery.txt', 'w') as file:
    for line in lines:
        # 去掉每行末尾的逗号（如果有的话），并写入新文件
        if line.endswith(',\n'):
            line = line[:-2] + '\n'  # 去掉末尾的逗号和换行符，然后添加换行符
        elif line.endswith(','):
            line = line[:-1]  # 只去掉末尾的逗号
        file.write(line)
